import {request} from "@/api";
import type {
    dataArticle, dataAvailable, dataCancel,
    dataCollect,
    dataConsultList,
    dataHealth, dataPreList, dataSomeOneAnt, dataSubmit,
    dataSwiper
} from "@/api/home/index/indexData";
import type {LocationQueryValue} from "vue-router";
// 登录与注册
// 先登录


// 轮播图
const getSwiper = function (data: dataSwiper) {
    return request({method: 'get', url: '/slideshow/list', data: data})
}
// 咨询师的基本信息
const getConsultAnt = function () {
    return request({method: 'get', url: '/system/teacher/list?pageNum:1&pageSize:100'})
}
const getAntID = function (id: string | null | LocationQueryValue[]) {
    return request({method: 'get', url: `/system/teacher/${id}`})
}
// 查看文章列表
const getArticleList = function (data: dataArticle) {
    return request({method: 'get', url: '/system/article/list', data: data})
}

const getCategory = function (data:any) {
    return request({method: 'get', url: '/system/category/list', data: data})
};

// 预约协议
const getAgreement = function () {
    return request({method: 'get', url:'/appointment/agreement'})
}

const getArticleID = function (id: string | null | LocationQueryValue[]) {
    return request({method: 'get', url: `/system/article/${id}`})
}

//获取客服电话
const getPhoneNum = function () {
    return request({method: 'get', url: "/system/dict/data/type/customer_service"})
}
// 获取日期时间段
const getDateTimes = function () {
    return request({method: 'get', url: "/schedule/dateTimeSpans"})
}

// 开始预约不可用
const getStartPre = function (data: any) {
    return request({method: 'post', url: "/appointment", data: data})
}

//某个咨询师的排期列表
const getSomeOneAnt = function (data: dataSomeOneAnt) {
    return request({method: 'get', url: "/schedule/list", data: data})
}

// 咨询师列表
const getTeacherList = function () {
    return request({method: 'get', url: "/system/teacher/list",})
}


// 获取某个咨询师的排期
const getSchedule = function (date: any, id: any) {
    return request({method: 'get', url: `/schedule/list?date=${date}&teacherId=${id}`,})
}

// 先获取日期与时间
const getTimeAnt = function () {
    return request({method: 'get', url: "/time/list",})
}

// 查询可预约的咨询师
const getAvailableTeachers = function (data: dataAvailable) {
    return request({method: 'get', url: "/system/teacher/availableTeachers", data: data})
}


// 提交预约
const getSubmit = function (data: dataSubmit) {
    return request({method: 'post', url: "/appointment/commit", data: data})
}

// 获取学生个人信息
const getStudentInfo = function () {
    return request({method: 'get', url: "system/student/info ",})
}


// 我的预约
const getMinePre = function () {
    return request({method: 'get', url: "/appointment/me",})
}
// 预约列表
const getPreList = function (data: dataPreList) {
    return request({method: 'get', url: "/appointment/list", data: data})
}
// 预约详情
// @ts-ignore
const getPreID = function (id) {
    return request({method: 'get', url: `/appointment/${id}`})
}

// 取消预约
const getCancelPre = function (data: dataCancel) {
    return request({method: 'post', url: '/appointment/cancel', data: data})
}
// 我的咨询列表
const getConsultList = function (data: dataConsultList) {
    return request({method: 'get', url: "/appointment/me/completed", data: data})
}
// 咨询列表详情
const getConsultID = function (id: string | null | LocationQueryValue[]) {
    return request({method: 'get', url: `/appointment/${id}`})
}


// 我的收藏
const getCollectList = function (data: dataCollect) {
    return request({method: 'get', url: "/system/collect/list", data: data})
}
// 健康中心介绍
const getHealthList = function (data: dataHealth) {
    return request({method: 'get', url: "/platform/text/list", data: data})
}

// 搜索根据名称
const getSearchList = function (name: { name: string | undefined | null | LocationQueryValue[] }) {
    return request({method: 'get', url: "/system/article/research", data: name})
}


const getTimer = function () {
    return request({method: 'get', url: '/schedule/dateTimeSpans?dateOffset=1'})
}

//我的消息
const getMessage = function (id:number) {
    return request({method: 'get', url: `/system/list/list/${id}`})
}
const getMessageDetails = function (id:number) {
    return request({method: 'get', url: `/system/message/${id}`})
}
const getRead = function (data:any) {
    return request({method: 'post', url: '/system/list/update', data })
}

export {
    getSwiper, getConsultAnt, getAntID, getArticleList, getArticleID, getPhoneNum,
    getCollectList, getHealthList, getMinePre, getPreList, getPreID, getCancelPre,
    getConsultList, getConsultID, getStartPre, getDateTimes, getSomeOneAnt, getTimeAnt,
    getAvailableTeachers, getSubmit, getSchedule, getTeacherList, getStudentInfo, getSearchList,
    getCategory,getAgreement,getTimer,getMessage,getMessageDetails,getRead
}